﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;



namespace 水费管理系统
{
    public partial class Form_login : Form
    {
        public DataSet1.用户Row user;
        public Form_login()
        {
            InitializeComponent();
            toolTip1.SetToolTip(comboBox_user, "请输入用户名,默认管理员为admin");
            toolTip1.SetToolTip(textBox_password, "请输入密码,默认为88888");
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void btn_login_Click(object sender, EventArgs e)
        {
            if (comboBox_user.Text.Trim() == "") 
            {
                MessageBox.Show("请输入用户名!", "警告", MessageBoxButtons.OK);
                comboBox_user.Focus();
                return;
            }
            this.用户TableAdapter.FillPassby用户名(this.dataSet1.用户,comboBox_user.Text.Trim());
            if(this.dataSet1.用户.Rows.Count!=1)
            {
                MessageBox.Show("不存在该用户名!", "警告", MessageBoxButtons.OK);
                comboBox_user.Focus();
                return;
            }
            if(this.dataSet1.用户[0].密码!=textBox_password.Text)
            {
                MessageBox.Show("密码错误!", "警告", MessageBoxButtons.OK);
                textBox_password.Focus();
                return;
            }
            user = this.dataSet1.用户[0];
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void Form_login_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“dataSet1.用户”中。您可以根据需要移动或移除它。
        //    this.用户TableAdapter.Fill(this.dataSet1.用户);

        }

        private void Form_login_FormClosing(object sender, FormClosingEventArgs e)
        {

        }


    }
}